package com.qinggeng.project.system.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.qinggeng.common.utils.StringUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.ArrayUtils;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Table(name = "company")
@Data
public class Company implements Serializable {
    /**
     * 公司Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @ApiModelProperty(value = "id(id为空时为新增，不为空时为更新)")
    private Long id;

    /**
     * 公司名称
     */
    @ApiModelProperty(value = "公司名称",required = true)
    private String name;

    /**
     * 公司规模
     */
    @ApiModelProperty(value = "公司规模",required = true)
    private String scale;

    /**
     * 公司地址
     */
    @ApiModelProperty(value = "公司地址",required = true)
    private String address;

    /**
     * 经度
     */
    @ApiModelProperty(value = "经度",required = true)
    private Float lng;

    /**
     * 纬度
     */
    @ApiModelProperty(value = "纬度",required = true)
    private Float lat;

    /**
     * 公司logo
     */
    @ApiModelProperty(value = "公司logo",required = true)
    private String logo;

    /**
     * 营业执照
     */
    @ApiModelProperty(value = "营业执照",required = true)
    private String license;


    @ApiModelProperty(hidden = true)
    private Long jobUserId;

    /**
     * 公司介绍
     */
    @ApiModelProperty(value = "公司介绍",required =true)
    private String introduce;

    /**
     * 环境照片
     */
    @ApiModelProperty(value ="环境照片",required = true)
    private String pictures;

    private boolean isDefault=false;

    /**
     * 公司福利
     */
    @ApiModelProperty(value ="公司福利",required = true)
    private String benefits;

    @ApiModelProperty(hidden = true)
    private String[] benefitsArray;
    /**
     * 状态（10=审核中20=审核通过30=审核未通过）
     */
    @ApiModelProperty(hidden = true)
    private String status;

    private String addressInfo;

    private String classifyCode;

    private String classifyName;

    private Date createTime;

    private Date updateTime;

    private static final long serialVersionUID = 1L;


    public boolean getIsDefault() {
        return this.isDefault;
    }

    public void setIsDefault(boolean isDefault) {
        this.isDefault = isDefault;
    }

    public String[] getBenefitsArray() {
        if(StringUtils.isEmpty(this.benefits)){
           return new String[0];
        }
        return this.benefits.split(",");
    }

    public void setBenefitsArray(String[] benefitsArray) {
        this.benefitsArray = benefitsArray;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", name=").append(name);
        sb.append(", scale=").append(scale);
        sb.append(", address=").append(address);
        sb.append(", lng=").append(lng);
        sb.append(", lat=").append(lat);
        sb.append(", logo=").append(logo);
        sb.append(", license=").append(license);
        sb.append(", introduce=").append(introduce);
        sb.append(", pictures=").append(pictures);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}
